package org.yookiee.support.core;

import org.yookiee.support.config.EasyI18nProperties;
import org.yookiee.support.toolkits.SpringContextToolkit;

/**
 * FileName DefaultTimeZone
 * Package org.yookiee.support.core
 * Description
 * author cpstory
 * create 2023-10-27 9:03
 * version V1.0
 */
public class DefaultTimeZone {

    private static EasyTimeZone DEFAULT_TIME_ZONE;

    static {
        EasyI18nProperties easyI18nProperties = SpringContextToolkit.getBean(EasyI18nProperties.class);
        // 如果未指定默认时区，默认使用中国时区
        DEFAULT_TIME_ZONE = easyI18nProperties == null ? EasyTimeZone.ASIA_SHANGHAI :
                EasyTimeZone.formatByTimeZone(easyI18nProperties.getDefaultConfig().getTimezone());
    }

    public static String defaultTimeZoneCode(){
        return DEFAULT_TIME_ZONE.getTimezone();
    }

    public static EasyTimeZone defaultTimeZone(){
        return DEFAULT_TIME_ZONE;
    }
}

